/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Oct 20, 2009 1:10:42 AM $
 *
 * Author: Eric Yang
 * Date  : Oct 20, 2009 1:10:42 AM
 *
 */
package com.gooex.web.action.gbuy.common;

import java.util.ArrayList;
import java.util.List;

import com.gooex.domain.base.Category;
import com.gooex.web.action.BaseAnonymousAction;


/**
 * @author Eric Yang
 * @version 1.0
 */
public class GetCategories extends BaseAnonymousAction {

	private String id;

	private List<Category> categories = new ArrayList<Category>();

	private Category category;

	public String execute() throws Exception {
		try {
			category = categoryManager.getCategory(id);
			if (category == null)
				categories = categoryManager.getMenuTopCategories();
			else
				categories = categoryManager.getCategories(category);
		} catch (Exception e) {
			addActionError(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	public Category getCategory() {
		return category;
	}

	public List<Category> getCategories() {
		return categories;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

}
